package beanInfo;

/**
 * 把信息从数据库实体类中抽取出来，避免对数据库实体类过度侵入
 */
public class UserInfo {

    public final static int MAX_ACCOUNT_LENGTH = 24; //限制账号最大长度
    public final static int MIN_ACCOUNT_LENGTH = 4; //限制账号最小长度
    public final static int MAX_PWD_LENGTH = 16; //限制密码最大长度
    public final static int MIN_PWD_LENGTH = 6; //限制密码最小长度

    public static boolean isAccountAndPwdLengthLegal(String account, String pwd) {
        if (account == null || pwd == null) return false;
        int accountLength = account.getBytes().length;
        int pwdLength = pwd.getBytes().length;
        return accountLength <= MAX_ACCOUNT_LENGTH && accountLength >= MIN_ACCOUNT_LENGTH
                && pwdLength <= MAX_PWD_LENGTH && pwdLength >= MIN_PWD_LENGTH;
    }
}
